import { createStore } from 'vuex'
import { login, add, getquanzhanlist, byst,del } from "../API/request";

export default createStore({
  state: {
    token: "",
    info:{},                //tab切换时的标题和标题前两个字的小写字母用于请求指定的数据    
    major:"qianduan",       //专业
  },
  getters: {},
  mutations: {
    token(state, token) {
      localStorage.setItem("token", token);
      state.token = token;
    },
  },
  actions: {
    // 登录
    getlogin({ commit }, obj) {
      return new Promise((reslove) => {
        login(obj).then((res) => {
          reslove(res);
          commit("token", res.token);
        });
      });
    },
    // 添加学生
    addStudent(a, obj) {
      return new Promise((reslove) => {
        add(obj).then((res) => {
          reslove(res);
        });
      });
    },
    getquanzhan(a, obj) {
      return new Promise((reslove) => {
        getquanzhanlist(obj).then((res) => {
          reslove(res);
        });
      });
    },
    by(a, obj) {
      return new Promise((reslove) => {
        byst(obj).then((res) => {
          reslove(res);
        });
      });
    },
    dels(a, obj) {
      return new Promise((reslove) => {
        del(obj).then((res) => {
          reslove(res);
        });
      });
    },
  },
  modules: {},
});
